using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;

using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;

using data;
using Common;

namespace product
{
    partial class View_store_ProductList : PortalModuleBase, IActionable
    {
    #region Private 
        //private void ShowProductList()
        //{
        //    try
        //    {
        //        string fileName;
        //        int numItem = Common.systemSettings.sysTypicalProductMaxRow * Common.systemSettings.sysTypicalProductPerRow;
        //        string mySQLCmd =
        //        "SELECT  TOP " + numItem + " a.productId,a.name1,b.fileName" +
        //        " FROM tm_product a INNER JOIN tm_product_file b ON a.productId = b.productId " +
        //        " WHERE a.grade='" + Common.consts.constTypicalGrade + "' AND " +
        //        " a.status='" + Common.consts.constStatusENABLE + "'";

        //        SqlConnection conn = new SqlConnection(Common.sysLibs.GetConnectionString);
        //        SqlDataAdapter daTmp = new SqlDataAdapter(new SqlCommand(mySQLCmd, conn));
        //        DataTable dataTbl = new DataTable();
        //        daTmp.Fill(dataTbl);
        //        conn.Close();
        //        ArrayList dataArr = new ArrayList();
        //        for (int idx = 0; idx < dataTbl.Rows.Count; idx++)
        //        {
        //            controls_logoList.myImgLinkInfo imgInfo = new controls_logoList.myImgLinkInfo();
        //            imgInfo.linkUrl = DotNetNuke.Common.Globals.NavigateURL("viewdetail", "mid=1", "userId=1");
        //            fileName = dataTbl.Rows[idx]["fileName"].ToString();
        //            imgInfo.imgPath = System.Web.HttpContext.Current.Request.ApplicationPath +
        //                              Common.sysLibs.GetUpLoadProductDir + "/" + Common.sysLibs.GetHashString(fileName) + "/" + fileName;
        //            imgInfo.description = Common.sysLibs.GetSubStr(dataTbl.Rows[idx]["name1"].ToString(),
        //                                                Common.systemSettings.sysNumberOfWordUnderLogo);
        //            dataArr.Add(imgInfo);
        //        }
        //        Tm_LogoList1.Display(dataArr, Common.systemSettings.sysTypicalProductPerRow);
        //    }
        //    catch (Exception exc)
        //    {
        //        Exceptions.ProcessModuleLoadException(this, exc);
        //    }
        //}

    #endregion

    #region Public Methods

    public bool DisplayAudit()
    {
        bool retValue = false;

        if ((string)Settings["auditinfo"] == "Y")
        {
            retValue = true;
        }

        return retValue;
    }

    #endregion

        #region Event Handlers

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                
                if (!Page.IsPostBack)
                {
                    int ownerId = Common.appLibs.GetOwnerIdFromStore(PortalId);
                    if (ownerId <= 0)
                    {
                        Response.Redirect(Common.appLibs.GetErrorURL(PortalId));
                        return;
                    }
                    this.Parent.Parent.Parent.Visible = (typicalProductLogoList.ShowProductList(ownerId) > 0);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }

        }


        #endregion

        #region Optional Interfaces

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Registers the module actions required for interfacing with the portal framework
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public ModuleActionCollection ModuleActions
        {
            get
            {
                ModuleActionCollection Actions = new ModuleActionCollection();
                Actions.Add(this.GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, this.LocalResourceFile), ModuleActionType.AddContent, "", "", this.EditUrl(), false, SecurityAccessLevel.Edit, true, false);
                return Actions;
            }
        }

        #endregion
}
}

